<template>
  <div>
    <div class="mb-4">
      <div v-if="data.btmodify">
        <el-button v-prmis="'config_update'" type="primary" @click="modify">{{
          $t("public.modify")
        }}</el-button>
      </div>
      <div v-else>
        <div v-if="!isField">
          <el-button type="success" @click="preserve">{{
            $t("public.save")
          }}</el-button>
          <el-button type="danger" @click="cancel">{{
            $t("public.cancel")
          }}</el-button>
        </div>
        <div v-else>
          <el-button type="success" @click="onSave">{{
            $t("public.save")
          }}</el-button>
          <el-button type="danger" @click="onDel">{{
            $t("public.del")
          }}</el-button>
        </div>
      </div>
    </div>

    <el-form
      :model="data.info"
      :inline="true"
      class="w-full"
      label-width="160"
      v-loading="data.mtloading"
    >
      <el-collapse v-model="data.activeName">
        <div
          class="flex flex-wrap h-8 leading-8 mb-6 mt-4"
          v-if="data.isPwd && !data.btmodify"
        >
          <span class="text-[red] mt-1">*</span>
          <div class="ml-2">{{ $t("public.password") }}：</div>
          <div class="w-2/12">
            <el-input
              v-model="data.pwd"
              :placeholder="$t('message.pleaseloginPass')"
              show-password="true"
              clearable
            />
          </div>
        </div>

        <!-- 基本信息 -->
        <el-collapse-item :name="1" class="basis" v-if="!isField">
          <template #title>
            <div
              class="h-8 text-base pl-4 mt-2 font-semibold relative text-[#fafafa]"
            >
              {{ $t("machine.configs.basic") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.inveAlert') + ':'"
                  prop="stock_warning"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.stock_warning || "0"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.stock_warning"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.maxNum') + ':'"
                  prop="recycle_bin_capacity"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.recycle_bin_capacity
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.recycle_bin_capacity"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.switch') + ':'"
                  prop="recycle_bin_full_buy"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.recycle_bin_full_buy == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.recycle_bin_full_buy"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.goodsBrow') + ':'"
                  prop="show_goods"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.show_goods == 1
                      ? $t("machine.configs.modeSwitch")
                      : $t("machine.configs.fixedMode")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.show_goods"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.modeSwitch')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.fixedMode')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.viewBrow') + ':'"
                  prop="show_goods_view"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.show_goods_view == 1
                      ? $t("machine.configs.listView")
                      : $t("machine.configs.shelfView")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.show_goods_view"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.listView')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.shelfView')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.sort') + ':'"
                  prop="goods_sort"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.goods_sort == 1
                      ? $t("machine.configs.recommendingGood")
                      : data.info.goods_sort == 2
                      ? $t("machine.configs.promotionalGood")
                      : $t("machine.configs.gift")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.goods_sort"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.recommendingGood')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.promotionalGood')"
                      :value="2"
                    />
                    <el-option :label="$t('machine.configs.gift')" :value="3" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.tel') + ':'"
                  prop="deal_service_phone"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.deal_service_phone || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.deal_service_phone"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.sideCode') + ':'"
                  prop="cabinet_tray_rotation"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.cabinet_tray_rotation || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.cabinet_tray_rotation"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.lightCode') + ':'"
                  prop="cabinet_light"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.cabinet_light || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.cabinet_light"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.lightEffect') + ':'"
                  prop="light_effect"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.light_effect == 1
                      ? $t("machine.configs.aware")
                      : $t("machine.configs.fully")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.light_effect"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.aware')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.fully')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 购物流程 -->
        <el-collapse-item :name="2" class="buy" v-if="!isField">
          <template #title>
            <div
              class="h-8 text-base pl-4 mt-2 font-semibold relative text-[#fafafa]"
            >
              {{ $t("machine.configs.shoppPro") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.proConfig') + ':'"
                  prop="buy_flow"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.buy_flow == 1
                      ? $t("machine.configs.default")
                      : $t("machine.configs.shopScan")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.buy_flow"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.default')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.shopScan')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="data.info.buy_flow == 2">
                <el-form-item
                  :label="$t('machine.configs.QRlink') + ':'"
                  prop="qr_code"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.qr_code || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.qr_code"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="data.info.buy_flow == 2">
                <el-form-item
                  :label="$t('machine.configs.QRdesc') + ':'"
                  prop="qr_desc"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.qr_desc || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.qr_desc"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 交易信息 -->
        <el-collapse-item :name="3" class="transaction" v-if="!isField">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.configs.transaction") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.taxSwitch') + ':'"
                  prop="tax_switch"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.tax_switch == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.tax_switch"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="data.info.tax_switch == 1">
                <el-form-item
                  :label="$t('machine.configs.taxName') + ':'"
                  prop="tax_name"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.tax_name || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.tax_name"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="data.info.tax_switch == 1">
                <el-form-item
                  :label="$t('machine.configs.taxRatio') + ':'"
                  prop="tax_rate"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.tax_rate || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.tax_rate"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.maxQuantity') + ':'"
                  prop="limit_quantity"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.limit_quantity || $t("machine.configs.unlimited")
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.limit_quantity"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.maxAmount') + ':'"
                  prop="limit_amount"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.limit_amount || "0.00"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.limit_amount"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.payType') + ':'"
                  prop="pay_type"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    getpya(data.info.pay_type)
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.pay_type"
                    :placeholder="$t('message.pleaseSelect')"
                    multiple
                    clearable
                  >
                    <el-option
                      v-for="item of data.payarr"
                      :label="$t(item.label)"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </div>
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.scannerSwitch') + ':'"
                  prop="scan_pick_up"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.backsweeper == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.backsweeper"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 高级设置 -->
        <el-collapse-item :name="4" class="senior" v-if="!isField">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.addMachine.senior") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.fullVideo') + ':'"
                  prop="full_screen_video"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.full_screen_video == 1
                      ? $t("machine.configs.loopPlay")
                      : $t("machine.configs.playSwitch")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.full_screen_video"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.loopPlay')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.playSwitch')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs. pickScan') + ':'"
                  prop="scan_pick_up"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.scan_pick_up == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.scan_pick_up"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs. emailLang') + ':'"
                  prop="email_lang"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    getemaillang(data.info.email_lang)
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.email_lang"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      v-for="(item, index) in data.langarr"
                      :key="index"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs. cargoChannel') + ':'"
                  prop="buy_channel"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.buy_channel == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.buy_channel"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs. prePickup') + ':'"
                  prop="preclaim"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.preclaim == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.preclaim"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.randomPickup') + ':'"
                  prop="random_pickup"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.random_pickup == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.random_pickup"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.together') + ':'"
                  prop="more_out"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.more_out == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.more_out"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.vip') + ':'"
                  prop="member_login"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.member_login == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.member_login"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.openVideo') + ':'"
                  prop="door_video"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.door_video == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.door_video"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.face') + ':'"
                  prop="face_identification"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.face_identification == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.face_identification"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.grocerystoreswitch') + ':'"
                  prop="pre_loading"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.pre_loading == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.pre_loading"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 优惠信息 -->
        <el-collapse-item :name="5" class="preferential">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.configs.discount") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.getDiscounts') + ':'"
                  prop="discount_show"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.discount_show == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.discount_show"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.activePictures') + ':'"
                  prop="discount_show"
                  class="w-11/12"
                >
                  <div class="inline-block" v-if="data.btmodify">
                    <img
                      :src="data.info.discount_pic || product"
                      class="max-w-20 max-h-28"
                    />
                  </div>
                  <el-select
                    v-if="!data.btmodify"
                    v-model="data.info.discount_pic"
                    :placeholder="$t('message.pleaseSelect')"
                    clearable
                    filterable
                    style="width: 94%"
                  >
                    <el-option
                      v-for="item of data.imgarr"
                      :key="item.res_id"
                      :label="item.res_id + '-' + item.title"
                      :value="item.file_path"
                    />
                  </el-select>
                  <el-icon
                    v-if="!data.btmodify"
                    style="width: 6%"
                    size="20"
                    @click="urlimg(data.info.discount_pic)"
                  >
                    <Picture />
                  </el-icon>
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 打印凭条 -->
        <el-collapse-item :name="6" class="Printing">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.configs.receipt") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.summarize.printer') + ':'"
                  prop="printer_disable"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.printer_disable == 1
                      ? $t("public.disable")
                      : $t("public.enable")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.printer_disable"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.disable')" :value="1" />
                    <el-option :label="$t('public.enable')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.billTemplate') + ':'"
                  prop="note_model"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.note_model == 1
                      ? $t("machine.configs.universal")
                      : $t("machine.configs.other")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.note_model"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.universal')"
                      :value="1"
                    />
                    <el-option
                      :label="$t('machine.configs.other')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="!isField">
                <el-form-item
                  :label="$t('machine.configs.electronic') + ':'"
                  prop="receipt"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.receipt == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.receipt"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="!isField">
                <el-form-item
                  :label="$t('machine.configs.displays') + ':'"
                  prop="result_receipt"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.result_receipt == 1
                      ? $t("public.open")
                      : $t("public.close")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.result_receipt"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('public.open')" :value="1" />
                    <el-option :label="$t('public.close')" :value="2" />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="!isField">
                <el-form-item
                  :label="$t('machine.configs.printReceipt') + ':'"
                  prop="printer_model"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.printer_model == 1
                      ? $t("machine.configs.auto")
                      : $t("machine.configs.manual")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.printer_model"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option :label="$t('machine.configs.auto')" :value="1" />
                    <el-option
                      :label="$t('machine.configs.manual')"
                      :value="2"
                    />
                  </el-select>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.customText') + ':'"
                  prop="receipt_desc"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.receipt_desc || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.receipt_desc"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.QRcode') + '1:'"
                  prop="discount_show"
                  class="w-11/12"
                >
                  <div class="inline-block" v-if="data.btmodify">
                    <img
                      :src="data.info.receipt_code1 || product"
                      class="max-w-20 max-h-28"
                    />
                  </div>
                  <el-select
                    v-if="!data.btmodify"
                    v-model="data.info.receipt_code1"
                    :placeholder="$t('message.pleaseSelect')"
                    clearable
                    filterable
                    style="width: 94%"
                  >
                    <el-option
                      v-for="item of data.imgarr"
                      :key="item.res_id"
                      :label="item.res_id + '-' + item.title"
                      :value="item.file_path"
                    />
                  </el-select>
                  <el-icon
                    v-if="!data.btmodify"
                    style="width: 6%"
                    size="20"
                    @click="urlimg(data.info.receipt_code1)"
                  >
                    <Picture />
                  </el-icon>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.QRcode') + '2:'"
                  prop="discount_show"
                  class="w-11/12"
                >
                  <div class="inline-block" v-if="data.btmodify">
                    <img
                      :src="data.info.receipt_code2 || product"
                      class="max-w-20 max-h-28"
                    />
                  </div>
                  <el-select
                    v-if="!data.btmodify"
                    v-model="data.info.receipt_code2"
                    :placeholder="$t('message.pleaseSelect')"
                    clearable
                    filterable
                    style="width: 94%"
                  >
                    <el-option
                      v-for="item of data.imgarr"
                      :key="item.res_id"
                      :label="item.res_id + '-' + item.title"
                      :value="item.file_path"
                    />
                  </el-select>
                  <el-icon
                    v-if="!data.btmodify"
                    style="width: 6%"
                    size="20"
                    @click="urlimg(data.info.receipt_code2)"
                  >
                    <Picture />
                  </el-icon>
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.QRcode') + '3:'"
                  prop="discount_show"
                  class="w-11/12"
                >
                  <div class="inline-block" v-if="data.btmodify">
                    <img
                      :src="data.info.receipt_code3 || product"
                      class="max-w-20 max-h-28"
                    />
                  </div>
                  <el-select
                    v-if="!data.btmodify"
                    v-model="data.info.receipt_code3"
                    :placeholder="$t('message.pleaseSelect')"
                    clearable
                    filterable
                    style="width: 94%"
                  >
                    <el-option
                      v-for="item of data.imgarr"
                      :key="item.res_id"
                      :label="item.res_id + '-' + item.title"
                      :value="item.file_path"
                    />
                  </el-select>
                  <el-icon
                    v-if="!data.btmodify"
                    style="width: 6%"
                    size="20"
                    @click="urlimg(data.info.receipt_code3)"
                  >
                    <Picture />
                  </el-icon>
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 交易结果 -->
        <el-collapse-item :name="7" class="delive">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.configs.results") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.mainTitle') + ':'"
                  prop="deal_success_title"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.deal_success_title || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.deal_success_title"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.failedTitle') + ':'"
                  prop="deal_fail_title"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.deal_fail_title || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.deal_fail_title"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.tel') + ':'"
                  prop="service_tel_show"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.service_tel_show == 1
                      ? $t("machine.configs.display")
                      : $t("machine.configs.hide")
                  }}</span>
                  <el-select
                    v-else
                    v-model="data.info.service_tel_show"
                    :placeholder="$t('message.pleaseSelect')"
                  >
                    <el-option
                      :label="$t('machine.configs.display')"
                      :value="1"
                    />
                    <el-option :label="$t('machine.configs.hide')" :value="2" />
                  </el-select>
                  <!-- <el-input v-else v-model="data.info.service_tel_show" :placeholder="$t('message.pleaseEnter')" style="width: 100%;"/> -->
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.succesSubtitle') + ':'"
                  prop="deal_success_sub_title"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.deal_success_sub_title || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.deal_success_sub_title"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.failedSubtitle') + ':'"
                  prop="deal_fail_sub_title"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.deal_fail_sub_title || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.deal_fail_sub_title"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.errorPic') + ':'"
                  prop="deal_abnormal_pic"
                  class="w-11/12"
                >
                  <div class="inline-block" v-if="data.btmodify">
                    <img
                      :src="data.info.deal_abnormal_pic || product"
                      class="max-w-20 max-h-28"
                    />
                  </div>
                  <el-select
                    v-if="!data.btmodify"
                    v-model="data.info.deal_abnormal_pic"
                    :placeholder="$t('message.pleaseSelect')"
                    clearable
                    filterable
                    style="width: 94%"
                  >
                    <el-option
                      v-for="item of data.imgarr"
                      :key="item.res_id"
                      :label="item.res_id + '-' + item.title"
                      :value="item.file_path"
                    />
                  </el-select>
                  <el-icon
                    v-if="!data.btmodify"
                    style="width: 6%"
                    size="20"
                    @click="urlimg(data.info.deal_abnormal_pic)"
                  >
                    <Picture />
                  </el-icon>
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 取货出货 -->
        <el-collapse-item :name="8" class="Take">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.configs.pick") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.pickuPage') + ':'"
                  prop="claim_goods_title"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.claim_goods_title || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.claim_goods_title"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.shipment') + ':'"
                  prop="out_goods_title"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.out_goods_title || "--"
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.out_goods_title"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>

        <!-- 机器配置 -->
        <el-collapse-item :name="9" class="machine">
          <template #title>
            <div class="h-8 text-base pl-4 mt-2 font-semibold text-[#fafafa]">
              {{ $t("machine.configs.machine") }}
            </div>
          </template>

          <template #default>
            <div class="w-full flex flex-wrap">
              <div class="w-1/3" v-if="!isField">
                <el-form-item
                  :label="$t('machine.configs.homeTimeout') + ':'"
                  prop="terminal_timeout"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify"
                    >{{ data.info.terminal_timeout || "0" }}
                    {{ $t("public.seconds") }}</span
                  >
                  <el-input
                    v-else
                    v-model="data.info.terminal_timeout"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3" v-if="!isField">
                <el-form-item
                  :label="$t('machine.configs.adTimeout ') + ':'"
                  prop="adv_timeout"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify"
                    >{{ data.info.adv_timeout || "0" }}
                    {{ $t("public.seconds") }}</span
                  >
                  <el-input
                    v-else
                    v-model="data.info.adv_timeout"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>

              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.purchaseTab ') + ':'"
                  prop="buy_normal_tab"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.buy_normal_tab
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.buy_normal_tab"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.fixedTab ') + ':'"
                  prop="buy_fix_tab"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{ data.info.buy_fix_tab }} </span>
                  <el-input
                    v-else
                    v-model="data.info.buy_fix_tab"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.hotelTag') + ':'"
                  prop="buy_hotel_tab"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{
                    data.info.buy_hotel_tab
                  }}</span>
                  <el-input
                    v-else
                    v-model="data.info.buy_hotel_tab"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
              <div class="w-1/3">
                <el-form-item
                  :label="$t('machine.configs.sortTag') + ':'"
                  prop="buy_hotel_tab"
                  class="w-11/12"
                >
                  <span v-if="data.btmodify">{{ data.info.buy_tab_sort }}</span>
                  <el-input
                    v-else
                    v-model="data.info.buy_tab_sort"
                    :placeholder="$t('message.pleaseEnter')"
                    style="width: 100%"
                  />
                </el-form-item>
              </div>
            </div>
          </template>
        </el-collapse-item>
      </el-collapse>
    </el-form>

    <el-dialog
      v-model="data.demonstrate"
      :title="$t('machine.addMachine.material')"
      center
      width="30%"
    >
      <div class="flex justify-center">
        <el-image class="max-w-80" :src="data.file_path" fit="fill" />
      </div>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
import { useI18n } from "vue-i18n";
const { t: $t } = useI18n();
import { getlang } from "@/api/manage";
import { getresourceList } from "@/api/advment";
import {
  getconfigFind,
  addconfigList,
  updateconfigList,
  deltconfiLang,
} from "@/api/machine";
import { checkPwd } from "@/api/common";
import getPlevel from "@/utils/level";
import product from "@/assets/product.png";
let emit = defineEmits(["investigate", "submitLang", "mcId",'delLang']);
let props = defineProps({
  info: {
    type: Object,
    default: {},
  },
  machineLangList: {
    type: Array,
    default: [],
  },
  isField: {
    type: Boolean,
    default: true,
  },
  btmodify: {
    type: Boolean,
    default: true,
  },
});

let data = reactive({
  isPwd: false,
  pwd: "",
  btmodify: true, // 按钮状态
  mtloading: false, // 加载状态
  demonstrate: false, // 素材演示
  activeName: [1, 2, 3, 4, 5, 6, 7, 8, 9],
  imgarr: [], // 图片素材
  pay_type: [], // 选中的支付类型
  langarr: [], // 语言列表
  payarr: [], // 支付类型
  file_path: "", // 素材链接
  original: "", // 保存原始数据，防止污染
  mc_obj: {}, // 配置信息
  info: {
    buy_flow: 1,
    qr_code: "",
    qr_desc: "",
    tax_switch: 2,
    tax_name: "",
    tax_rate: "",
    limit_quantity: "",
    limit_amount: "",
    pay_type: "",
    unionpay_terminal_number: "",
    scan_pick_up: 2,
    email_lang: "",
    buy_channel: 2,
    preclaim: 1,
    random_pickup: 2,
    more_out: 1,
    member_login: 2,
    door_video: 2,
    face_identification: 2,
    pre_loading: 2,
    printer_disable: 1,
    note_model: 1,
    printer_model: 1,
    receipt: 2,
    receipt_code1: "",
    receipt_code2: "",
    receipt_code3: "",
    receipt_desc: "",
    result_receipt: 2,
    deal_success_title: "",
    deal_success_sub_title: "",
    deal_abnormal_pic: "",
    deal_fail_title: "",
    deal_fail_sub_title: "",
    deal_service_phone: "",
    terminal_timeout: "",
    adv_timeout: "",
    volume: "",
    show_goods: 2,
    show_goods_view: 1,
    goods_sort: 1,
    cabinet_tray_rotation: "",
    cabinet_light: "",
    light_effect: 1,
    claim_goods_title: "",
    out_goods_title: "",
    discount_show: 2,
    discount_pic: "",
    stock_warning: 2,
    recycle_bin_capacity: $t("machine.configs.unlimited"),
    recycle_bin_full_buy: 1,
    expire_notice: "",
    full_screen_video: 1,
    service_tel_show: 2,
    buy_normal_tab: "",
    buy_fix_tab: "",
    buy_hotel_tab: "",
    backsweeper: 2,
    buy_tab_sort: "",
  },
});
watchEffect(() => {
  if (props.isField) {
    if (props.machineLangList.length) {
      data.info.printer_disable = props.machineLangList[0].printer_disable;
      data.info.note_model = props.machineLangList[0].note_model;
      data.info.receipt = props.machineLangList[0].receipt;
      data.info.receipt_code1 = props.machineLangList[0].receipt_code1;
      data.info.receipt_code2 = props.machineLangList[0].receipt_code2;
      data.info.receipt_code3 = props.machineLangList[0].receipt_code3;
      data.info.receipt_desc = props.machineLangList[0].receipt_desc;
      data.info.deal_success_title =
        props.machineLangList[0].deal_success_title;
      data.info.deal_success_sub_title =
        props.machineLangList[0].deal_success_sub_title;
      data.info.deal_abnormal_pic = props.machineLangList[0].deal_abnormal_pic;
      data.info.deal_fail_title = props.machineLangList[0].deal_fail_title;
      (data.info.deal_fail_sub_title =
        props.machineLangList[0].deal_fail_sub_title),
        (data.info.claim_goods_title =
          props.machineLangList[0].claim_goods_title);
      data.info.out_goods_title = props.machineLangList[0].out_goods_title;
      data.info.discount_show = props.machineLangList[0].discount_show;
      data.info.discount_pic = props.machineLangList[0].discount_pic;
      data.info.buy_normal_tab = props.machineLangList[0].buy_normal_tab;
      data.info.buy_fix_tab = props.machineLangList[0].buy_fix_tab;
      data.info.buy_hotel_tab = props.machineLangList[0].buy_hotel_tab;
      data.info.buy_tab_sort = props.machineLangList[0].buy_tab_sort;
    } else {
      data.info = {
        printer_disable: 1,
        note_model: 1,
        receipt: 2,
        receipt_code1: "",
        receipt_code2: "",
        receipt_code3: "",
        receipt_desc: "",
        deal_success_title: "",
        deal_success_sub_title: "",
        deal_abnormal_pic: "",
        deal_fail_title: "",
        deal_fail_sub_title: "",
        light_effect: 1,
        claim_goods_title: "",
        out_goods_title: "",
        discount_show: 2,
        discount_pic: "",
        buy_normal_tab: "",
        buy_fix_tab: "",
        buy_hotel_tab: "",
        buy_tab_sort: "",
      };
    }
  }
});
watch(props, (n, o) => {
  if (props.btmodify) {
    data.btmodify = props.btmodify;
  }
});
let onSave = () => {
  let parm = {
    printer_disable: data.info.printer_disable,
    note_model: data.info.note_model,
    receipt: data.info.receipt,
    receipt_code1: data.info.receipt_code1,
    receipt_code2: data.info.receipt_code2,
    receipt_code3: data.info.receipt_code3,
    receipt_desc: data.info.receipt_desc,
    deal_success_title: data.info.deal_success_title,
    deal_success_sub_title: data.info.deal_success_sub_title,
    deal_abnormal_pic: data.info.deal_abnormal_pic,
    deal_fail_title: data.info.deal_fail_title,
    deal_fail_sub_title: data.info.deal_fail_sub_title,
    claim_goods_title: data.info.claim_goods_title,
    out_goods_title: data.info.out_goods_title,
    discount_show: data.info.discount_show,
    discount_pic: data.info.discount_pic,
    buy_normal_tab: data.info.buy_normal_tab,
    buy_fix_tab: data.info.buy_fix_tab,
    buy_hotel_tab: data.info.buy_hotel_tab,
    buy_tab_sort: data.info.buy_tab_sort,
  };
  // 添加
  if (!props.machineLangList.length) {
    parm.mc_id = data.mc_obj.mc_id;
    emit("submitLang", parm, 3);
  }
  // 编辑
  if (props.machineLangList.length && props.machineLangList[0].mcl_id) {
    emit("submitLang", parm, 4);
  }
};
let onDel = () => {
  deltconfiLang({ mcl_id: props.machineLangList[0].mcl_id }).then((res) => {
    data.info = {
      printer_disable: 1,
      note_model: 1,
      receipt: 2,
      receipt_code1: "",
      receipt_code2: "",
      receipt_code3: "",
      receipt_desc: "",
      deal_success_title: "",
      deal_success_sub_title: "",
      deal_abnormal_pic: "",
      deal_fail_title: "",
      deal_fail_sub_title: "",
      light_effect: 1,
      claim_goods_title: "",
      out_goods_title: "",
      discount_show: 2,
      discount_pic: "",
      buy_normal_tab: "",
      buy_fix_tab: "",
      buy_hotel_tab: "",
      buy_tab_sort: "",
    };
    data.btmodify = true;
    emit("delLang");
    ElMessage({
      message: $t("message.delSuccess"),
      type: "success",
    });
  });
};
// 获取配置信息
let getlist = () => {
  let info = props.info;
  getconfigFind({ m_id: info.m_id }).then((res) => {
    if (res.state == 200) {
      for (let key in data.info) {
        data.info[key] = res.data[key];
      }
      data.mc_obj.mc_id = res.data.mc_id;
      data.mc_obj.mc_title = res.data.mc_title;
      data.pay_type = [];
      emit("mcId", res.data.mc_id);
      let pya = data.info.pay_type.split(",");
      for (let item of pya) {
        data.pay_type.push(item * 1);
      }
      data.original = JSON.stringify(data.info);
    }
  });
};

// 修改按钮
let modify = () => {
  data.pwd = "";
  data.isPwd = true;
  data.mtloading = true;
  setTimeout(() => {
    data.btmodify = false;
    data.mtloading = false;
  }, 500);
};

// 保存按钮
let preserve = () => {
  if (!data.pwd) {
    ElMessage({
      message: $t("message.pleaseEnterPass"),
      type: "error",
    });
    return;
  }
  checkPwd({ pwd: data.pwd }).then((res) => {
    let info = props.info;
    data.info.pay_type = data.pay_type.join(",");
    data.mtloading = true;
    data.isPwd = false;
    if (data.mc_obj.mc_id == undefined) {
      // 添加配置信息
      data.info.m_id = info.m_id;
      data.info.machine_id = info.machine_id;
      addconfigList(data.info).then((res) => {
        data.mtloading = false;
        data.btmodify = true;
        if (res.state == 200) {
          ElMessage({
            message: $t("message.addSuccess"),
            type: "success",
          });
          getlist();
          return;
        }
        ElMessage({
          message: $t("message.networkFailed"),
          type: "error",
        });
      });
    } else {
      // 修改配置信息
      data.info.mc_id = data.mc_obj.mc_id;
      data.info.mc_title = data.mc_obj.mc_title;
      updateconfigList(data.info).then((res) => {
        data.mtloading = false;
        data.btmodify = true;
        if (res.state == 200) {
          ElMessage({
            message: $t("message.modifySuccess"),
            type: "success",
          });
          getlist();
          return;
        }
        ElMessage({
          message: $t("message.networkFailed"),
          type: "error",
        });
      });
    }
  });
};

// 取消按钮
let cancel = () => {
  data.info = JSON.parse(data.original);
  data.pay_type = [];
  let pya = data.info.pay_type.split(",");
  for (let item of pya) {
    data.pay_type.push(item * 1);
  }
  data.btmodify = true;
};

// 支付类型
let getpya = (e) => {
  let payname = "--";
  if (e == undefined) {
    return payname;
  }
  let type = e.split(",");
  let arr = [];
  for (let item of type) {
    arr.push($t(getPlevel.getPpay(item, 2)));
  }
  payname = arr.join(",");
  return payname;
};

// 邮件语言
let getemaillang = (e) => {
  let name = "--";

  for (let item of data.langarr) {
    if (e == item.value) {
      name = item.label;
    }
  }

  return name;
};

// 查看素材
let urlimg = (e) => {
  if (e == "") {
    return;
  }
  data.demonstrate = true;
  data.file_path = e;
};

// 获取信息
let getadvlist = () => {
  data.original = JSON.stringify(data.info);
  data.imgarr = [];
  data.payarr = [];
  // 素材列表
  getresourceList({ type: 1 }).then((res) => {
    if (res.state == 200) {
      for (let item of res.data) {
        if (item.status == 1) {
          data.imgarr.push(item);
        }
      }
    }
  });

  // 支付类型
  let pay = getPlevel.getPpay("", 1);
  for (let i = 1; i < pay.length; i++) {
    data.payarr.push(pay[i]);
  }

  // 获取语言列表
  getlang().then((res) => {
    if (res.state == 200) {
      for (let item of res.data) {
        data.langarr.push({
          label: item.name + " - " + item.lang,
          value: item.lang,
        });
      }
    }
  });
};

getadvlist();
getlist();
</script>
<style type="text/css">
.basis .el-collapse-item__header {
  background: rgba(75, 141, 284, 0.8);
}

.basis .el-collapse-item__wrap {
  border: 1px solid rgba(75, 141, 284, 0.4);
}

.buy .el-collapse-item__header {
  background: rgba(255, 97, 3, 0.8);
  margin-top: 20px;
}

.buy .el-collapse-item__wrap {
  border: 1px solid rgba(255, 97, 3, 0.4);
}

.transaction .el-collapse-item__header {
  background: rgba(133, 191, 79, 0.8);
  margin-top: 20px;
}

.transaction .el-collapse-item__wrap {
  border: 1px solid rgba(133, 191, 79, 0.4);
}

.senior .el-collapse-item__header {
  background: rgba(299, 100, 121, 0.8);
  margin-top: 20px;
}

.senior .el-collapse-item__wrap {
  border: 1px solid rgba(299, 100, 121, 0.4);
}

.preferential .el-collapse-item__header {
  background: rgba(197, 92, 193, 0.8);
  margin-top: 20px;
}

.preferential .el-collapse-item__wrap {
  border: 1px solid rgba(197, 92, 193, 0.4);
}

.Printing .el-collapse-item__header {
  background: rgba(224, 144, 63, 0.8);
  margin-top: 20px;
}

.Printing .el-collapse-item__wrap {
  border: 1px solid rgba(224, 144, 63, 0.4);
}

.delive .el-collapse-item__header {
  background: rgba(122, 70, 60, 0.8);
  margin-top: 20px;
}

.delive .el-collapse-item__wrap {
  border: 1px solid rgba(122, 70, 60, 0.4);
}

.Take .el-collapse-item__header {
  background: rgba(186, 174, 160, 0.8);
  margin-top: 20px;
}

.Take .el-collapse-item__wrap {
  border: 1px solid rgba(186, 174, 160, 0.4);
}

.machine .el-collapse-item__header {
  background: rgba(181, 180, 186, 0.8);
  margin-top: 20px;
}

.machine .el-collapse-item__wrap {
  border: 1px solid rgba(181, 180, 186, 0.4);
}

.el-collapse-item__content {
  padding-top: 20px;
  padding-bottom: 0;
}

.el-collapse-item__arrow {
  color: #fafafa;
}
</style>
